﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Domotica.Gazing.Calibration
{
    internal class CalibratorScreen
    {
        public CalibratorScreen(int number, Screen screen)
        {
            Number = number;
            Screen = screen;
        }

        public PointF TrackPointTopLeft;
        public PointF TrackPointBottomRight;

        public int Number { get; set; }
        public Screen Screen { get; set; }

        public Point GetCenter(Size form)
        {
            Rectangle b = Screen.Bounds;
            return new Point(b.X + b.Width / 2 - form.Width/2, b.Y + b.Height / 2 - form.Height/2);
        }
        public Point GetCenter()
        {
            Rectangle b = Screen.Bounds;
            return new Point(b.X + b.Width / 2, 
                b.Y + b.Height / 2);
        }

        public Point TopLeft(Size form)
        {
            Rectangle b = Screen.Bounds;
            return new Point(b.Left, b.Top);
        }

        public Point BottomRight(Size form)
        {
            Rectangle b = Screen.Bounds;
            return new Point(b.Right - form.Width, b.Bottom - form.Height);
        }

        public void SetTrackPointTopLeft(GazeClickEventArgs e)
        {
            TrackPointTopLeft = e.TrackingPoint;
        }

        public void SetTrackPointBottomRight(GazeClickEventArgs e)
        {
            TrackPointBottomRight = e.TrackingPoint;
        }
    }

    internal class CalibratorScreenList : List<CalibratorScreen>
    {
        public CalibratorScreen GetPrimary()
        {
            return this.Find(p => p.Screen.Primary);
        }
    }
}
